package com.cheifsteam.springframework.context.support;

import com.cheifsteam.springframework.beans.BeansException;
import com.cheifsteam.springframework.beans.factory.ConfigurableListableBeanFactory;
import com.cheifsteam.springframework.beans.factory.support.DefaultListableBeanFactory;

/**
 * @author 屈燃希
 * @date 2025/1/30 16:18
 * @content
 */
public abstract class AbstractRefreshableApplicationContext  extends AbstractApplicationContext{


    private DefaultListableBeanFactory beanFactory;

    @Override
    protected void refreshBeanFactory() throws BeansException {

        DefaultListableBeanFactory beanFactory = createBeanFactory();
        loadBeanDefinitions(beanFactory);
        this.beanFactory = beanFactory;
    }
    private DefaultListableBeanFactory createBeanFactory() {
        return new DefaultListableBeanFactory();
    }

    protected abstract void loadBeanDefinitions(DefaultListableBeanFactory beanFactory);

    @Override
    protected ConfigurableListableBeanFactory getBeanFactory() {
        return beanFactory;
    }

}
